<template>
	<view class="container">
		<view class="title_goods_name">{{goods.healthy_title}}</view>
		<view class="title_remark">{{goods.desc}}</view>

		<view class="menu_title">
			<view class="content_name">图文说明</view>
			<view class="line"></view>
		</view>
		<view class='shop_info_view'>
<!--			<rich-text :nodes="goods.content"></rich-text>-->
			<mp-html :content="goods.content" />
		</view>

		<view class="foot"></view>
	</view>
</template>
<script>
	//#ifdef H5
	import wxjs   from '../../jweixin/lib/index.js';
	//#endif
	import toMpWeixin from '../../js_sdk/wzc-toMpWeixin/toMpWeixin.js';
	export default {
		data() {
			return {
				width:'',
				height:'',
				h:'',
				pic_h:'',
				goods:{},
				price:[],
				banner:[],
				logo:'',
				goods_w:'',
				id:0,
				use_price:0,
				price_id:0,
				number:1,
				commission:0,
				display:0,
				start_status:1,
				goods_status:1,
				specs:'选择规格',
				site:'',
				open_status:0,
        area_status:0,
				original:'',
				integral:0,
        open:1,
        area_value:'',
        title1:'',
				msg:'',
				type:'exchange',//exchange 积分兑换；buy  直接购买
				url: getApp().globalData.url,
				static_url:getApp().globalData.static
			}
		},
		onLoad(e) 
		{
			var res = uni.getSystemInfoSync();
			var w = res.windowWidth;
			this.goods_w  = 4*150+"px";
			this.h = res.windowHeight+"px";
			this.height = w*4/4+"px";
			this.width  = w+"px";
			this.y = w-20+"px";
			this.pic_h  = w*0.96*0.25+"px";
			this.id     = e.id;
		},
		onShow(){
			this.initialize();
		},
		//#ifdef MP-WEIXIN
		onShareAppMessage(res) {
			var member_id = uni.getStorageSync("member_id");
			if(member_id=="")
			{
				var upid = 0;
			}
			else
			{
				var upid = member_id;
			}
			var title       = '谷牧之道-'+this.goods.goods_name;
			var imgurl      = this.logo;
			// var imgurl  = "https://zhangjie.jdmuguzhid.com/web/static/img/a.png";
			return {
			  title: title,
			  path: '/pages/mall/goods_detail?upid='+upid+'&id='+this.goods.goods_id,
			  imageUrl:imgurl
			}
		},
		onShareTimeline(res)
		{
			var member_id = uni.getStorageSync("member_id");
			if(member_id=="")
			{
				var upid = 0;
			}
			else
			{
				var upid = member_id;
			}
			var title       = '谷牧之道-'+this.goods.goods_name;
			var imgurl      = this.logo;
			// var imgurl  = "https://zhangjie.jdmuguzhid.com/web/static/img/a.png";
			return {
			  title: title,
			  query: 'upid='+upid+'&id='+this.goods.goods_id,
			  imageUrl:imgurl
			}
		},
		//#endif
		methods: {
			share_config:function()
			{
				var that  = this;
				var site  = window.location.href;
				this.site = site;
				uni.request({
					url: this.url+"/wechat_share",
					data: {url:site},
					header: {'Content-Type': 'application/json'},
					success: function (res) 
					{
						console.log(res.data);
						wxjs.config({
						  debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
						  appId: res.data.appId,         // 必填，公众号的唯一标识
						  timestamp: res.data.timestamp, // 必填，生成签名的时间戳
						  nonceStr: res.data.nonceStr,   // 必填，生成签名的随机串
						  signature: res.data.signature,        // 必填，签名
						  jsApiList: ['updateAppMessageShareData','updateTimelineShareData']            // 必填，需要使用的JS接口列表
						  // jsApiList:["onMenuShareTimeline","onMenuShareAppMessage","showMenuItems","hideMenuItems"]
						});
						wxjs.ready(function () {
							var shareData1 = {
								title:'谷牧之道-'+that.goods.goods_name, // 分享标题
								desc: '一站式购物平台，厂家产品会员价', // 分享描述  全国健康类产品，
								link: that.url+'/wap?#/pages/mall/goods_detail?id='+that.id+"&/",  // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
								imgUrl: that.url+that.goods.imgurl, // 分享图标
								// type: '', // 分享类型,music、video或link，不填默认为link
								// dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
								success: function () {
									console.log("设置成功");
								}
							};
							var shareData2 = {
								title:'谷牧之道-'+that.goods.goods_name, // 分享标题
								link: that.url+'/wap?#/pages/mall/goods_detail?id='+that.id+"&/",  // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
								imgUrl: that.url+that.goods.imgurl, // 分享图标
								success: function () {
									console.log("设置成功");
								}
							};
							wxjs.updateAppMessageShareData(shareData1);
							wxjs.updateTimelineShareData(shareData2);
						})
						
					}
				})
			},
			home:function()
			{
				uni.switchTab({url:"/pages/mall/index"});
			},
			initialize:function()
			{
				var that = this;
				var member_id = uni.getStorageSync("member_id");

				uni.request({
					url: this.url+'/wechat_healthy_detail',
					data: {id:this.id},
					header: {'Content-Type': 'application/json'},
					success: (res) => {
						that.goods = res.data.result[0];

						//#ifdef H5
						var ua = navigator.userAgent.toLocaleLowerCase();
						if(ua.match(/MicroMessenger/i) == 'micromessenger')
						{
							this.site = window.location.href;
							this.share_config();
						}
						//#endif
					}
				});
			},
		}
	}
</script>
<style>
	page{background: #F4F4F4;}
	.container {background: #ffffff;}
	.dialog_pic image{width: 100%;}
	.specs_unit image{width:60upx;margin-right:20upx;}
	.goods_property image{width:50upx;height: 50upx;}
	.title_price text{text-decoration: line-through;color: #CCCCCC;font-size:40upx;padding-left:20upx;}
	.share image{width:45upx;height: 45upx;}
	.title_goods_name{text-align:center;width:92%;padding:0 4%;font-size: 36upx;line-height: 50upx;font-weight: bold;color: #282828;background: #FFFFFF;padding-top: 5%;}
	.title_remark{margin-top:5%;text-align:center;width:92%;padding:0 4%;font-size: 26upx;color: #999;line-height: 35upx;background: #FFFFFF;}
	.service image{width:100%;}
	.shop_name image{width: 50%;}
	.shop_info_view{margin-bottom: 150upx;width:96%;color: #282828;font-size: 24upx;padding:0 2%;line-height: 50upx;}
	.shop_info_view image{width:100%;}
	.menu_title{margin-top:5%;width:96%;padding:10upx 2%;height: 80upx;display: flex;justify-content:center;align-items: center;flex-direction: column;position:relative;}
	.content_name{font-size:80upx;padding:0 50upx;background: #F4F4F4;font-size:36upx;z-index:99;}
	.line{width:60%;height: 1px;background: #CCCCCC;position: absolute;top: 50upx;z-index: 9;}
	.jian image{width:30upx;height: 30upx;}
	.list_unit image{width:50upx;height: 50upx;}
	.foot {margin-top: 10%;width:1px;height: 10px;}
</style>
